<?xml version="1.0"?>

<st-source>
<time-stamp>From VisualWorks® NonCommercial, 7.6 of March 3, 2008 on April 14, 2009 at 3:36:30 pm</time-stamp>


<class>
<name>ExpensiveItemFirstPolicy</name>
<environment>SupplyChain</environment>
<super>SupplyChain.Policy</super>
<private>false</private>
<indexed-type>none</indexed-type>
<inst-vars></inst-vars>
<class-inst-vars></class-inst-vars>
<imports></imports>
<category></category>
<attributes>
<package>SupplyChain</package>
</attributes>
</class>

<comment>
<class-id>SupplyChain.ExpensiveItemFirstPolicy</class-id>
<body>A Policy which sells the most expensive item first

</body>
</comment>

<methods>
<class-id>SupplyChain.ExpensiveItemFirstPolicy</class-id> <category>initialize-release</category>

<body package="SupplyChain" selector="initialize">initialize
	"Initialize a newly created instance. This method must answer the receiver."

	super initialize.
	" *** Replace this comment with the appropriate initialization code *** "
	^self</body>
</methods>

<methods>
<class-id>SupplyChain.ExpensiveItemFirstPolicy</class-id> <category>controlling</category>

<body package="SupplyChain" selector="determineSellItem:">determineSellItem: anSku
	" *** This method was defined by SupplyChain.Policy as a subclass responsibility.
	Replace its body with a proper implementation. *** "

	| expensive items |
	"pick the items with this SKU"
	"SELECT * INTO item FROM inventory WHERE NOT EXISTS (SELECT * INTO i FROM inventory WHERE (i != item) AND (item.sellPrice &gt; i.sellPrice))"
	items := self inventory items select: [ :i | i sku = anSku ].
	expensive := items first.
	items do:
		[ :item |
		(item buyPrice &gt; expensive buyPrice)
			ifTrue: [ expensive := item. ]
		].
	^expensive.</body>
</methods>

</st-source>
